package com.legal.controller.practice;


import com.legal.domain.po.QuestionCategory;
import com.legal.domain.result.Result;
import com.legal.domain.vo.QuestionCategoryVO;
import com.legal.service.practice.IQuestionCategoryService;
import com.legal.service.practice.IUserPracticeStatsService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 刷题功能模块 - 分类管理 控制器
 * </p>
 *
 * @author xiaopeng
 * @since 2025-06-27
 */
@RestController
@RequestMapping("/category")
@RequiredArgsConstructor
@Tag(name = "分类管理")  // OpenAPI 3.0 注解
public class CategoryController {

    private final IQuestionCategoryService categoryService;


    /**
     * 获取所有分类
     *
     */
    @Operation(summary = "获取所有分类")
    @GetMapping("/list")
    public Result<List<QuestionCategory>> list() {
        return Result.ok(categoryService.list());
    }

    /**
     * 获取所有分类（包含问题数量统计）
     * @return
     */
    @Operation(summary = "获取所有分类（包含问题数量统计）")
    @GetMapping("/listWithCount")
    public Result<List<QuestionCategoryVO>> listWithQuestionCount() {
        return Result.ok(categoryService.listWithQuestionCount());
    }

    /**
     * 获取热点分类 - 获取最近30天用户刷题量最多的分类
     */
    @Operation(summary = "获取热点分类")
    @GetMapping("/hotList")
    public Result<List<QuestionCategoryVO>> hotList() {
        return Result.ok(categoryService.getHotCategories());
    }


}
